/**
1.需要添加的组件
my_project
    build
    main
        CMakeLists.txt
        idf_component.yml   <--
        main.c
    CMakeLists.txt

idf_component.yml里面的内容如下
dependencies:
  idf: ">=5.1"
  lvgl/lvgl: ">=8.*"
  esp_lvgl_port: "^1"
  espressif/button: "^2"
*/

#include "driver/gpio.h"
#include "esp_lvgl_port.h"

#include "lvgl.h"

#define PREV_BTN 1
#define NEXT_BTN 2
#define ENTER_BTN 3

#define ACTIVE_LEVEL 0

void gpio_button_init(void)
{
    const button_config_t lv_button_config[3] = {
        {
            .type = BUTTON_TYPE_GPIO,
            .long_press_time = 1500,
            .short_press_time = 180,
            .gpio_button_config = {
                .gpio_num = PREV_BTN,
                .active_level = ACTIVE_LEVEL,
            },
        },
        {
            .type = BUTTON_TYPE_GPIO,
            .long_press_time = 1500,
            .short_press_time = 180,
            .gpio_button_config = {
                .gpio_num = NEXT_BTN,
                .active_level = ACTIVE_LEVEL,
            },
        },
        {
            .type = BUTTON_TYPE_GPIO,
            .long_press_time = 1500,
            .short_press_time = 180,
            .gpio_button_config = {
                .gpio_num = ENTER_BTN,
                .active_level = ACTIVE_LEVEL,
            },
        },
    };

    lv_disp_t *disp = lv_disp_get_default();
    const lvgl_port_nav_btns_cfg_t btns = {
        .disp = disp,
        .button_prev = &lv_button_config[0],
        .button_next = &lv_button_config[1],
        .button_enter = &lv_button_config[2],
    };
    lv_indev_t *indev_drv = lvgl_port_add_navigation_buttons(&btns);
    lv_group_t *g = lv_group_create();
    lv_group_set_default(g);
    lv_indev_set_group(indev_drv, g);
}